package controller.v1;


import com.usian.apis.wemedia.WmMaterialControllerApi;
import com.usian.common.wemedia.WemediaContans;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmMaterialDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import service.WmMaterialService;

@RestController
@RequestMapping("/wemedia/api/v1")
public class WmMaterialController implements WmMaterialControllerApi {
    @Autowired
    private WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    @Override
    public ResponseResult fileUpload(MultipartFile multipartFile) {
        return wmMaterialService.fileUpload(multipartFile);
    }

    @PostMapping("/list")
    @Override
    public ResponseResult findList(@RequestBody WmMaterialDto dto) {
        return wmMaterialService.findList(dto);
    }

    @GetMapping("/del_picture/{id}")
    @Override
    public ResponseResult delById(@PathVariable Integer id) {
        return wmMaterialService.delById(id);
    }
    @GetMapping("/collect/{id}")
    @Override
    public ResponseResult collect(@PathVariable Integer id) {
        return wmMaterialService.setIsCollection(id, WemediaContans.COLLECT_MATERIAL);
    }
    @GetMapping("/cancel_collect/{id}")
    @Override
    public ResponseResult cancelCollect(@PathVariable Integer id) {
        return wmMaterialService.setIsCollection(id, WemediaContans.CANCEL_COLLECT_MATERIAL);
    }

}
